#include "comm.hpp"

int main()
{
    key_t key = ftok(PATHNAME, PROJ_ID);
    if(key<0)
    {
        Log("create key fail", Debug) << " client key : " << key << endl;
    }
    Log("create key done", Debug) << " client key : " << key << endl;

    int shmid=shmget(key,SHM_SIZE,0);
    if(shmid<0)
    {
        Log("get shm fail", Debug) << " : " << shmid << endl;
        exit(2);
    }
    Log("get shm done", Debug) << " : " << shmid << endl;

    char* shmaddr=(char*)shmat(shmid,nullptr,0);
    if(shmaddr==nullptr)
    {
        Log("attach shm fail", Debug) << " : " << shmid << endl;
        exit(3);
    }
    Log("attach shm done", Debug) << " : " << shmid << endl;

    int n=shmdt(shmaddr);
    assert(n!=-1);
    Log("detach shm done", Debug) << " : " << shmid << endl;

    return 0;
}